﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SensorMash
{
    class ArduinoData
    {

//        static SerialPort _serialPort;

//        static private void CSUpdateServo(CallFrame frame)
//       {

//           // Use the following technique to get the "native" .NET
//values of the given arguments.

//           int servoAngle = frame.UnboxArgument<int>(0);     // Get
//the first argument (i.e., the argument at index 0) as a .NET double
//value.
//           string port = frame.UnboxArgument<string>(1);     // Get
//the second argument (i.e., the argument at index 1) as a .NET string
//value.


//           // Here's the main body of our function.

//           if (servoAngle>=0 && servoAngle <= 180)
//           {
//               // update angle

//               string message;
//               byte[] a = new byte[1];
//               a[0] = (byte)servoAngle;

//               _serialPort.PortName = port; //for example "COM6"
//               _serialPort.BaudRate = 9600;
//               _serialPort.Open();
//               message = System.Text.ASCIIEncoding.ASCII.GetString
//(a);
//               _serialPort.Write(message);
//               _serialPort.Close();

//               Console.WriteLine("angle updated to \"{0}\" ",
//servoAngle);

//           }
//           else
//           {
//                //don't update anything
//           }


//       }


//        #include <Servo.h>

//Servo myservo;  // create servo object to control a servo

//int pos = 0;    // variable to store the servo position
//int incomingByte = 0;   // for incoming serial data

//void setup()
//{
// myservo.attach(9);  // attaches the servo on pin 9 to the servo
//object
// Serial.begin(9600);   // opens serial port, sets data rate to 9600
//bps
//}

//void loop()
//{

//       if (Serial.available() > 0) {
//               // read the incoming byte:
//               incomingByte = Serial.read();
//               if (incomingByte>=0 && incomingByte<=180)
//               {
//               // say what you got:
//               Serial.print("I received: ");
//               Serial.println(incomingByte, DEC);

//               pos = incomingByte;

//               Serial.print("turning servo to : ");
//               Serial.println(pos, DEC);

//               myservo.write(pos);              // tell servo to go
//to position in variable 'pos'
//               delay(15);                       // waits 15ms for the
//servo to reach the position
//               }

//       }


//}



    }
}
